<?php
/**
 * ccNewsletter
 * @author Chill Creations <info@chillcreations.com>
 * @link http://www.chillcreations.com
 * @license GNU/GPL
**/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

jimport( 'joomla.application.component.view' );

class ccNewsletterViewnewsletter extends JView
{
	function display($tpl = null)
	{
		// retrieve newsletter to view
		$newsletterRecord=& $this->get('Data');
		$isNew = ($newsletterRecord->id < 1);

		$text = $isNew ? JText::_( 'CC_NEW' ) : JText::_( 'CC_EDIT' );
		if($isNew)
		{
			JToolBarHelper::title(  JText::_( 'CC_NEWSLETTER_TITLE' ).': <small><small>[ ' . $text.' ]</small></small>' );
		}
		else
		{
			JToolBarHelper::title(  $newsletterRecord->name.': <small><small>[ ' . $text.' ]</small></small>' );
		}
		JToolBarHelper::save();
		JToolBarHelper::apply();
		if ($isNew)  {
			JToolBarHelper::cancel();
		} else {
			// for existing items the button is renamed `close`
			JToolBarHelper::cancel( 'cancel', 'Close' );
		}
		$this->assignRef('newsletterRecord',$newsletterRecord);
		parent::display($tpl);
	}
}
